<?php

/**
 * Framework_Presenter_RSS
 *
 * Present data as valid RSS feed. Note that unlike other presenters,
 *  Framework_Presenter_RSS requires that the data be structured in a
 * specific way.
 *
 * @author Application Support Group
 * @package BAMF
 */

class Framework_Presenter_RSS extends Framework_Presenter_Common {
	
	public function __construct(Framework_Module $module) {
		parent::__construct($module);
	}



	public function display() {
		$moduleData = $this->module->getData() ;
		$entries = $moduleData['entries'] ;
		$title = $moduleData['title'] ;
		$link = $moduleData['link'] ;
		$description = $moduleData['description'] ;
		$language = $moduleData['language'] ;

		header("Content-Type: text/xml");

		$_output = array() ;

		$_output[] = "<?xml version='1.0' encoding='UTF-8' ?>" ;
		$_output[] = "<rss version='2.0'>" ;
		$_output[] = "<channel>" ;
		$_output[] = "<title>$title</title>" ;
		$_output[] = "<link>$link</link>" ;
		$_output[] = "<description>$description</description>" ;
		$_output[] = "<language>$language</language>" ;
		$_output[] = "<copyright>Copyright ".date( 'Y' )." University System of Georgia</copyright>" ;
		$_output[] = "<lastBuildDate>".date( 'r' )."</lastBuildDate>" ;
		$_output[] = "<generator>".$_SERVER['HTTP_HOST']."</generator>" ;

		foreach( $entries as $entry ) {
			$_output[] =  "<item>" ;
			$_output[] =  "<title>".$entry['title']."</title>" ;
			$_output[] =  "<link>".$entry['link']."</link>" ;
			$_output[] =  "<pubDate>".$entry['pubDate']."</pubDate>" ;
			$_output[] =  "<description>".$entry['description']."</description>" ;
			$_output[] =  "</item>" ;
		}

		$_output[] =  "</channel>" ;
		$_output[] =  "</rss>" ;
		
		print( implode( "\n", $_output )) ;
	}



	public function __destruct() {
		parent::__destruct();
	}
}

?>
